/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package wat.ziszcommon.remote;

import java.lang.reflect.Proxy;
import wat.ziszcommon.invoker.MethodInvoker;

/**
 *
 * @author Krzysztof Wilkos
 */
public class RemoteModuleFactory {
    private static RemoteModuleFactory instance = null;
    private RemoteInvocationHandler handler;

    private RemoteModuleFactory(MethodInvoker invoker) {
        handler = new RemoteInvocationHandler(invoker);
    }

    public static RemoteModuleFactory newInstance(MethodInvoker invoker) {
        instance = new RemoteModuleFactory(invoker);
        return instance;
    }

    public static RemoteModuleFactory getInstance() {
        return instance;
    }

    public Object createProxy(Class interFace) {
        return Proxy.newProxyInstance(interFace.getClassLoader(), new Class[] { interFace }, handler);
    }
}
